package sweep;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.Serial;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import java.io.*;

public class Start extends JFrame {

    private static DataOutputStream out;

    public Start(Socket client, String rival) {
        JButton StartButton = new JButton("start");
        StartButton.addActionListener(e -> {
            try {
                out = new DataOutputStream(client.getOutputStream());
                out.writeUTF("game_start " + rival);
                System.out.println("game_start " + rival);
            } catch (IOException ee) {
                ee.printStackTrace();
                return;
            }
            Sweep.startGameBoard(client, rival);
            dispose();
        });
        StartButton.setBounds(50, 130 , 200 , 25);
        add(StartButton);
        add(new JLabel(""));
    }
}
